//
//  CDeck.m
//  CDeck
//
//  Created by Joan Bartrina Rapesta on 9/16/11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "Deck.h"

@implementation CDeck

- (id) init
{
    self = [super init];
    if (self) 
    {
        // Initialization code here.
        communityCard_Index = 0;
    }
    return self;
}

/**
 * Set valus of the m_appearedCards to false. Simulating sharing the deck
 */
- (void) shareDeck
{
    for(int i = 0; i < sizeof(m_appearedCards)/sizeof(bool); i++)
    {
        m_appearedCards[i] = false;
    }
}


/**
 * Returns int
 * Compute a random value between 2 and 53 not apeared previuosly. 
 * To find out the apeared values the m_appearedCards array is checked
 */
- (int) getCard
{
    int randomcard = 0;
    randomcard = (int) (arc4random() % 53);
    while ((randomcard < 2) || (m_appearedCards[randomcard] == true))
    {
        randomcard = (int) (arc4random() % 53);   
    }
    m_appearedCards[randomcard] = true;
    return randomcard;    
}

- (void) dealloc
{
	// don't forget to call "super dealloc"
	[super dealloc];
}

@end
